<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>去重</title>
</head>
<body>

</body>
<script type="text/javascript">

    //第一种方法   splice()
   /* function arr(arr){
        for(var i = 0;i<arr.length;i++){
            for(var j = i+1;j<arr.length;j++){
                if(arr[i] == arr[j]){
                    arr.splice(j,1);
                    j--;
                }
            }
        }
        return arr;
    }
    var ar = [2,2,5,3,5,8,5,6,,555,88566,2254,4455,2223,55];

    console.log(arr(ar));*/

    //第二种方法  indexOf（）的方法
    /*var arr = [2,5,2,3,5,3,8,5,8,5,26,5,4552,7];
    var add = [];
    for(var i = 0;i<arr.length;i++){
        if(add.indexOf(arr[i]) == -1){
            add.push(arr[i]);
        }
    }
    console.log(add);*/

    //第三种方法 includes()
    var arr = [2,5,2,3,5,3,8,5,8,5,26,5,4552,7];
    var add = [];
    for(var i = 0;i<arr.length;i++){
        if(!add.includes(arr[i])){
            add.push(arr[i]);
        }
    }
    console.log(add);

</script>

</html>